package com.it.sun.yuebike.base.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.it.sun.yuebike.base.model.entity.UserEntity;
import com.it.sun.yuebike.base.mapper.UserMapper;
import com.it.sun.yuebike.base.service.UserService;
import com.it.sun.yuebike.framework.model.dto.Result;
import com.it.sun.yuebike.framework.util.ResultUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author sunmannian
 * @since 2021-06-04
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {

    @Override
    public Result<UserEntity> getByOpenid(String openid) {
        UserEntity user = this.getOne(Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getOpenid, openid));
        return ObjectUtil.isNull(user) ? ResultUtils.error("") : ResultUtils.success(user);
    }
}
